<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <th:block th:include="include::header" />
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form" th:object="${craft}">
            <input type="hidden" name="cr_id" th:value="*{cr_id}" />

            <div class="layui-form-item">
                <label for="cr_name" class="layui-form-label">
                    <span class="x-red">*</span>工艺名称</label>
                <div class="layui-input-inline">
                    <input type="text" id="cr_name" name="cr_name" required="" lay-verify="cr_name" autocomplete="off" th:value="*{cr_name}"
                           class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="cr_price" class="layui-form-label">
                    <span class="x-red">*</span>外协价格</label>
                <div class="layui-input-inline">
                    <input type="text" id="cr_price" name="cr_price" required="" lay-verify="cr_price" th:value="*{cr_price}"
                           autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="cr_bottleneck" class="layui-form-label">
                    <span class="x-red">*</span>瓶颈工序工期
                </label>
                <div class="layui-input-inline">
                    <input type="cr_bottleneck" id="cr_bottleneck" name="cr_bottleneck" required="" lay-verify="cr_bottleneck" autocomplete="off" th:value="*{cr_bottleneck}"
                           class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="cr_standard" class="layui-form-label">
                    <span class="x-red">*</span>标准加工能力</label>
                <div class="layui-input-inline">
                    <input type="text" id="cr_standard" name="cr_standard" required="" lay-verify="cr_standard" th:value="*{cr_standard}"
                           autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="cr_overtime" class="layui-form-label">
                    <span class="x-red">*</span>加班标准加工能力</label>
                <div class="layui-input-inline">
                    <input type="text" id="cr_overtime" name="cr_overtime" required="" lay-verify="cr_overtime" th:value="*{cr_overtime}"
                           autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="cr_excess" class="layui-form-label">
                    <span class="x-red">*</span>加班超额加工能力</label>
                <div class="layui-input-inline">
                    <input type="text" id="cr_excess" name="cr_excess" required="" lay-verify="cr_excess" th:value="*{cr_excess}"
                           autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="cr_double" class="layui-form-label">
                    <span class="x-red">*</span>二倍工序能力</label>
                <div class="layui-input-inline">
                    <input type="text" id="cr_double" name="cr_double" required="" lay-verify="cr_double" th:value="*{cr_double}"
                           autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="cr_overload" class="layui-form-label">
                    <span class="x-red">*</span>超负荷工序能力</label>
                <div class="layui-input-inline">
                    <input type="text" id="cr_overload" name="cr_overload" required="" lay-verify="cr_overload" th:value="*{cr_overload}"
                           autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="edit" lay-submit="">修改</button>
            </div>
        </form>
    </div>
</div>
<script>layui.use(['form', 'layer', 'jquery'],
    function () {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;

        //监听提交
        form.on('submit(edit)',
            function (data) {
                console.log(data);
                //发异步，把数据提交给php
                $.ajax({
                    url:"/craft/manage/edit",
                    type: "POST",
                    data:data.field,
                    success(res){
                        if(res.success){
                            layer.alert("修改成功", {
                                    icon: 6
                                },
                                function () {
                                    //关闭当前frame
                                    xadmin.close();

                                    // 可以对父窗口进行刷新
                                    xadmin.father_reload();
                                });
                        }else{
                            layer.msg(res.msg)
                        }
                    }
                })
                return false;
            });

    });</script>
</body>

</html>